package com.hs.server.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hs.server.domain.VehQueuexxb;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface VehQueuexxbMapper extends BaseMapper<VehQueuexxb>{
    @Select("SELECT count(lsh) FROM veh_queuexxb WHERE zt = 0")
    int getWorkNum();

    @Select("SELECT * FROM veh_queuexxb WHERE zt=0 ORDER BY cjsj LIMIT 1")
    VehQueuexxb getNewWork();

    @Update("UPDATE veh_queuexxb SET zt = 3 WHERE lsh = #{lsh} AND zpzl = #{zpzl}")
    int updateZtByLsh(String lsh,String zpzl);//入队中

    @Update("UPDATE veh_queuexxb SET zt='0' where zt!='4'")
    void updateShzt();

    @Select("SELECT lsh FROM veh_queuexxb GROUP BY lsh HAVING COUNT(*) = SUM(zt IN ('2', '4')) ORDER BY MIN(cjsj) ASC limit 1;")
    String judgeTaskFinish();
}
